🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / domain / src / commonMain / kotlin / org / meshtastic / core / domain / usecase / settings / IsOtaCapableUseCase.kt
Displaying Raw • Download
core/domain/src/commonMain/kotlin/org/meshtastic/core/domain/usecase/settings/IsOtaCapableUseCase.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 2.99 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.domain.usecase.settings
Tff7b72import T7ee787kotlinx.coroutines.ExperimentalCoroutinesApi
Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787kotlinx.coroutines.flow.combine
Tff7b72import T7ee787kotlinx.coroutines.flow.flatMapLatest
Tff7b72import T7ee787kotlinx.coroutines.flow.flowOf
Tff7b72import T7ee787kotlinx.coroutines.flow.map
Tff7b72import T7ee787org.koin.core.annotation.Single
Tff7b72import T7ee787org.meshtastic.core.model.ConnectionState
Tff7b72import T7ee787org.meshtastic.core.repository.DeviceHardwareRepository
Tff7b72import T7ee787org.meshtastic.core.repository.NodeRepository
Tff7b72import T7ee787org.meshtastic.core.repository.RadioController
Tff7b72import T7ee787org.meshtastic.core.repository.RadioPrefs
Tff7b72import T7ee787org.meshtastic.core.repository.isBle
Tff7b72import T7ee787org.meshtastic.core.repository.isSerial
Tff7b72import T7ee787org.meshtastic.core.repository.isTcp
Tff7b72import T7ee787org.meshtastic.proto.HardwareModel
T8b949e/** Use case to determine if the currently connected device is capable of over-the-air (OTA) updates. */
Tff7b72interface T56d364IsOtaCapableUseCase Tb4b4b4{
Tff7b72operator Tff7b72fun Td2a8ffinvokeTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Tffa657BooleanTff7b72>
Tb4b4b4}
Tf0883e@OptInTb4b4b4(Te6edf3ExperimentalCoroutinesApiTff7b72::Te6edf3classTb4b4b4)
Tf0883e@Single
Tff7b72class T56d364IsOtaCapableUseCaseImplTb4b4b4(
Tff7b72private Tff7b72val Te6edf3nodeRepositoryTb4b4b4: Te6edf3NodeRepositoryTb4b4b4,
Tff7b72private Tff7b72val Te6edf3radioControllerTb4b4b4: Te6edf3RadioControllerTb4b4b4,
Tff7b72private Tff7b72val Te6edf3radioPrefsTb4b4b4: Te6edf3RadioPrefsTb4b4b4,
Tff7b72private Tff7b72val Te6edf3deviceHardwareRepositoryTb4b4b4: Te6edf3DeviceHardwareRepositoryTb4b4b4,
Tb4b4b4) Tb4b4b4: Te6edf3IsOtaCapableUseCase Tb4b4b4{
Tff7b72override Tff7b72operator Tff7b72fun Td2a8ffinvokeTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3FlowTff7b72<Tffa657BooleanTff7b72> Tff7b72=
Te6edf3combineTb4b4b4(Te6edf3nodeRepositoryTb4b4b4.Te6edf3ourNodeInfoTb4b4b4, Te6edf3radioControllerTb4b4b4.Te6edf3connectionStateTb4b4b4) Tb4b4b4{ Te6edf3nodeTb4b4b4, Te6edf3connectionState Tff7b72-Tff7b72>
Te6edf3node Te6edf3to Te6edf3connectionState
Tb4b4b4}
Tb4b4b4.Te6edf3flatMapLatest Tb4b4b4{ Tb4b4b4(Te6edf3nodeTb4b4b4, Te6edf3connectionStateTb4b4b4) Tff7b72-Tff7b72>
Tff7b72if Tb4b4b4(Te6edf3node Tff7b72=Tff7b72= Tff7b72null Tff7b72|Tff7b72| Te6edf3connectionState Tff7b72!Tff7b72= Te6edf3ConnectionStateTb4b4b4.Te6edf3ConnectedTb4b4b4) Tb4b4b4{
Te6edf3flowOfTb4b4b4(Tff7b72falseTb4b4b4)
Tb4b4b4} Tff7b72else Tff7b72if Tb4b4b4(Te6edf3radioPrefsTb4b4b4.Te6edf3isBleTb4b4b4(Tb4b4b4) Tff7b72|Tff7b72| Te6edf3radioPrefsTb4b4b4.Te6edf3isSerialTb4b4b4(Tb4b4b4) Tff7b72|Tff7b72| Te6edf3radioPrefsTb4b4b4.Te6edf3isTcpTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3hwModel Tff7b72= Te6edf3nodeTb4b4b4.Te6edf3userTb4b4b4.Te6edf3hw_model
Te6edf3deviceHardwareRepositoryTb4b4b4.Te6edf3observeDeviceHardwareTb4b4b4(Te6edf3hwModelTb4b4b4.Te6edf3valueTb4b4b4)Tb4b4b4.Te6edf3map Tb4b4b4{ Te6edf3hw Tff7b72-Tff7b72>
Te6edf3hwTff7b72?.Te6edf3let Tb4b4b4{
Tffa657itTb4b4b4.Te6edf3isEsp32Arc Tff7b72|Tff7b72|
Tffa657itTb4b4b4.Te6edf3architectureTb4b4b4.Te6edf3containsTb4b4b4(Ta5d6ff"Ta5d6ffnrfTa5d6ff"Tb4b4b4, Te6edf3ignoreCase Tff7b72= Tff7b72trueTb4b4b4) Tff7b72|Tff7b72|
Tffa657itTb4b4b4.Te6edf3requiresDfu Tff7b72=Tff7b72= Tff7b72true
Tb4b4b4} Tff7b72?: Tb4b4b4(Te6edf3hwModel Tff7b72!Tff7b72= Te6edf3HardwareModelTb4b4b4.Te6edf3UNSETTb4b4b4)
Tb4b4b4}
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3flowOfTb4b4b4(Tff7b72falseTb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s